Modified fitEdge funciton to include both endpoints in measurement
Bugfixes for fitEdge endpoint function