Split "update()" to sub-functions