fixed bugs in weighted queries