added empty checks for arrays and objects and NaN check for numbers