Eliminate duplicate code