updated error handling so an Error is always returned rather than an Error or string