fix code duplication