fixed up javascript so that it works correctly in chrome - issue 217