fixed bug with empty arrays