done with scala porting