first steps towards a JS version