Eliminate duplicated logic.