executing queries when passed a connection