upgraded sleep script