reducing duplicated code