added array and some checks