fix undefined bug in main controller