#19, #20 added sql testing algorithm