fix for empty array problem