Fixing bug in msgExists method.