coded MasterFSM

not debugged yet