tidied js code, and added a redirect to the base url when no query is given.