remove use of unflatten so that it runs ok on js
compile to js using prototype style