fixed nasty bug where enegry was lost