normalize function moved here