Fix resource query bug