started to refactor JS