Started refactoring the code. --wc