move code to do powersave into its own function