Update function.
Refactor code.