started porting to scala