Implement the main controller