make sleep conditional on nanosleep