[update:] reorganized code to be pretty