implement JS functions