Refactored code and better charging