eliminating duplicated code