catching errors from range throw