a little better error handling