Refactored code
Revert "Refactored code"

This reverts commit 1c3b0af8560e9ee89ae276add3786a386b0d5685.
Refactored code