Cleaned up normalize function