509 error check

pull request for #509