Refactor repeated operation