Modification with termination of infiniteloop