added logging to the query