Consolidated duplicated code.