Moved page creating logic from controller to model and added needed cache flush