Revert "some code refactoring"

This reverts commit 500a6f48b870660e6bed6c329458cacb3b4409ed.