refactored length normalization
refactored kernel normalization