added logic for collection and model and began template script on main page