remove duplicate code