minor refactor to js