Fix for the jquery looping problem