added and tested JavaScript rewriter