Updated code to further sanitize input.