removing duplication of code