[refactoring]removed duplicated logic.