fixed bad query