Fixed some bugs. Added some fault tolerance when results are empty