refactoring some codes in trainer, profiles and course implementations controllers