we are repeating too many times transitions[transition]. I would suggest we use an intermediate variable for it