Added some checks for empty messages