fixed problem with writing flow