reworked the JS to better model an object structure