Refactored away from code duplication