Rewriting some query crafting parts (especially those .find(' FROM '))