Fixes error in update function