fixed bug with flow state not being changed correctly