started refacotring and extracted code to modules