extracted update loop to function