updated sleepmode function