Refactory to avoid duplicated code