Removing the infinite loop