Further refactoring done to main