refactor js error