Revert "Delete duplicate code"

This reverts commit 6ccca50bc9a8baeef62258e6e90901d6c3c81baf.