add function to check and toggle power state