fix bug where results can appear in the wrong order

hey,

sometimes the results are not ordered correctly, this fixes the issue