correct the duplicated code