optimize sleep time