fix bug with empty arrays