Closes #14 improve the logic of "Random" query