bug fix for isLoop

Hi Roberto,

Please let me know if the js below can be improved.

~Christine