Bug in sanitize function