fixed nanosleep code