removing code duplication