Revert "using when."

This reverts commit 068cb8e2a22e13435245492584a379175332df5c.