flattened js a bit