implements unique algorithm

Meta: I have been meaning to write up my rationale for all the various design decisions I've made. I should bump the priority of that. It would make your life easier.