loop - improve sleep code