done porting + little fix