Added nanosleep to the application to allow for smaller sleep delays