some basic refactoring: