Refactored code to avoid repetition