a bit of refactoring...