Remove duplication of the code