outsourced js

and made interface more consistent