added function for updating U and removed it from main