Nested conditionals

Hi all,

I'm building a form with a serious of 10 trials, after which I need to identify the first trial number that the where the user answered correctly twice in a row. That is, if the user answers:
'trial1 - correct'
'trial2 - incorrect'
'trial3 - correct'
'trial4 - correct'
...
then the value displayed should be 4 (as in trial 4).

The only way I've managed to get this to work is with a calc like this:
if(selected(/data/PCM54_1, '1') and selected(/data/PCM54_2, '1'), '2',
if(selected(/data/PCM54_2, '1') and selected(/data/PCM54_3, '1'), '3',
if(selected(/data/PCM54_3, '1') and selected(/data/PCM54_4, '1'), '4',
if(selected(/data/PCM54_4, '1') and selected(/data/PCM54_5, '1'), '5',
if(selected(/data/PCM54_5, '1') and selected(/data/PCM54_6, '1'), '6',
if(selected(/data/PCM54_6, '1') and selected(/data/PCM54_7, '1'), '7',
if(selected(/data/PCM54_7, '1') and selected(/data/PCM54_8, '1'), '8',
if(selected(/data/PCM54_8, '1') and selected(/data/PCM54_9, '1'), '9',
if(selected(/data/PCM54_9, '1') and selected(/data/PCM54_10, '1'), '10',
'Not achieved')))))))))

This works. But the syntax makes my eyes bleed and is difficult to parse for others. I feel like I must be missing something here. Can anyone suggest something cleaner/saner?