refactored a method