added error catching for sql query