Revert "Code refactor" which broke the program

This reverts commit 998d25cc3cec458544202038b7e029a97ae66322.