small refactor to calling of js