Attempted to make state machine functional,it is being difficult