clean duplicated code