abstracted main js into separate files, added comments