refactored the SQL dialect out to make it pluggable