Reformatted output to be MVC friendly

Please refactor. The code keeps on calling out, saying it's utter shit.