this could be pulled out into a private method since its being used in both methods.