check results length to prevent setting data as undefined