reduce duplicated code