Moving common code of a method to seprate method and then calling

Removing blank spaces [ci skip]