added state machine handling to transformation