Update function and add test