refactored to use a method