Move table manipulation code into the window ready function