changed loop_pos to loop_start; added loop_end