refactor, clean up a bit