Added calculation for loop start and end positions (ms)