x can have different data types so we need to loop using lapply not apply