work in progress; I should refactor a lot of this soon