refactor method to eliminate duplicates
refactor method to eliminate duplicates