Fixed error where algorithm failed to account for final pivot point