updating build_uri method - changing variable scope