refactored section that reads and writes from uri io into smaller method called read_uri.