Fixed empty result exception

Signed-off-by: Wu Long <wulong@comp.nus.edu.sg>