infinite recursion for empty arrays bug