Added JS implementation