fixing bug caused by negative RepeatStart values