refactoring: extracted two methods