Fix undefined error

Make sure that `message` is defined before checking for it