gem query bug fixed