how to build a state flow chart