Break out main logic into reusable module