doing optimize during update