updated support for arrays
added array check