consolidated duplicated code