Added looping functionality to the cursor.