Pulled common code into a method
random changes