Revised code to account for special characters.