split update loop into three parts