Replace waiting for key press with sleeping