Added error checking for invalid url parameters