implement JS layer of logic