a bit of refactoring for the future