Feature/322 better encapsulate javascript