Fixed a bug causing loop guards to be checked twice