rewritten js