Fixed issue infinite loop

Infinite loop if startposition and endposition were both 0 fixed.