refactor js out of view files