updated code to work locally or via a webserver