Beyond mvc

This is a long complex method - consider refactoring.