remove duplicated code