added setLoops() function