Refactor (update the logic).