Refactor duplicated method