replaced more code with run_query method