added array checking