handle missing elements better and encode url parameters