Added error handling in case browser does not return "document.location.search" correctly eg. as is the case with firefox