Revert "Refactoring/rearranging the code."

This reverts commit 7a4e57d1d8240e776d4aa9696c185003fc08c5d2.