Can you please extract this logic into a separate method?