better encapsulating of js