added flow restoring and can run forever