Fixed bug in range measurement