update functions and unit test