Added check for null array value