minor code refactoring

diff and commit messages are pretty self explanatory