this is actually quite unnecessary - it would be easier to just leave the [0] access and catch any exceptions and use None instead.

Also if you could please attach tests.

Thanks!