refactor js views, abstract function included