some minor refactoring after the fact
oops, forgot to add some comments