Fixed sanitize function