Revert "removed duplicated code"

This reverts commit 49604f40e147d46875dd766919d4c49c890f728d.
Revert "Revert "removed duplicated code""

This reverts commit b20857b1a610fddc19170e13eae6aae7763dcff4.