almost finished porting