Changed timer to thread.sleep