add initial structure, convert groovy logic to js.