refactor home js