elimanting duplicated code