Revert "remove unused code"

This reverts commit 69707302027e0b031fb98729b72d707d0e9c4341.