refactor a method