Moved normization into a function