Error: list index smaller than 1

Here is some Pseudo code for you

If not is list empty of the list you get back from CloudDB
Then select the first item

You can learn how to work with lists here

Taifun