Refactor main js for displaying main section content