global wpdb instead of WP_Query; code cleanup