Complete JS implementation