Fixed main activity

There was an error if there were not more then 7 entries in the
database.