fixed normalizing function