fixed loop conditions, moved update of hu to the update method