fixing update to happen once per iteration