added ask and moved error handling