added safeNormalize for newer glm