Changed things to thread.sleep