Refactor Flow define