debugged version of updateFunction