Changed cr.execute to logged_query