bug solved for empty arrays