Updated code to work with the new Uri class