fixed bug causing to crash when discover returns 0 rows

Crashed when trying to access null element