Refacotring main