Refactoring - removing some duplication