This is minor, but this call should have been under the "if" clause because it will only be needed when "r != null".