Refactored long method in to different responsibilities