Can you please extract some meaningful functions from this method?