replaced normBySum with generic normalise function