code refactoring(extract common method)