got rid of some 'while's and 'sleep's