Move shared logic into seperate method