Adding check for element types of array before mapping