optimization of the main controller