refactor and added battery level