fixed the empty array issue