apply pattern refactoring extract method