A bit of refactoring...