refactored code to use more helper methods