closes #3; refactoring a few things to improve code quality (incomplete)