move the return r under the try block