cleanup duplicated code