if you switch to the promise api you can avoid all the error checking