Removing loop bug