a bit of refactoring..