Fixed a logic error that happened when there were no messages in db