Battery management logic