working on #42
huge refactors for #42