add error checking to all sql