fixed query rewriting part for the el case