made big changes to statemachine. More correct methode, but buggy atm :(