porting CTC lbarary