How a battery works