how do battery energy storage system works