Refactoring out of common functionality