Mgalctc refactoring code