Revert "simplify code"

This reverts commit 023a4788e77dcaa64a535ecdcb967de4928f6f06.