Refactor normalize.m