Revert "some refactoring"

This reverts commit ac95e792f11b7b31c24f45e4d1dfa34c0078ded1.
Revert "Revert "some refactoring""

This reverts commit 9a20ca3972a3a5685d266c482fc880097af5e0db.
Revert "some refactoring"

This reverts commit 5512000551d3ff3a2c8c97c46b0e59869096ccfc.