eliminate duplicated code