Improved battery function