refactored into method