Added a little better error handling