remove duplicate code and mixed tabs with spaces