fixing issues with non empty arrays