Improve executing query and prepared statement