Reduce duplicated code.