(U_pdate) clean up code and add better comments