get rid of code duplication