commit 2

UNTESTED. read the readme. this is borderline pseudocode.