cleanup: removing code duplication