add undefined/null check for to url