Added Some statemachine code. Only Proff f Concept