refactoring genCondSQL