Remove duplicate code