Changed JS to run on window ready to fix bug