added matrix normalization function