Remove duplicate code

Remove duplicate code