remove duplication of code