Added a check on count() for array