replace toCharArray method with convertStringToCharArray