refactored code out of index.html and into seperate directories