Handled case of no hits

The earlier implementation did not handle the cases where no hits were
obtained. This patch fixes the issue.

Signed-off-by: Vivek Rai <vivekraiiitkgp@gmail.com>