add size() validation for empty arrays