added charging state checking