refactoring code block in index.html into individual files