completes rewrite, optimized, prepped for MVC