fixed checking for empty messages