implementation in js