remove duplicated code.