Update main.js

Modify functions to use HTML templates