UPDATED: to remove invalid characters