Added check for valid transition in transitionTo