porting to js