Fixed looping behavior

I made sure two objects had the same type when I compared them