Fixed a small bug in the endpoint calculation routine