moved the heaving lifting to it's own file, modified templates