Made the code further object oriented for ease of understanding the workflow and proper decoupling