Removing unnecessary loops