Removed infinite loop and replaced it with an idle handler