Updated function "update"