eliminate duplicate code