lot of update
add flow graph
update close func