Replaced usleep with nanosleep