Add the buildSQL func which turns list of flag into SQL statement
Fix the flags