changes to allow SQL to be passed directly