transferred diagram flow to master.cc as comments