finish main training codes