renaming line segment, working out iteration strategies
pass error function as argument