aargh, forgot to finish the algorithm during abstraction