sleep function fixed