updated battery function