Added null check in BUildUri.