made battery script into a function