added some JS functionality. Not quite working all the way so currently commented out