Split helpers and control logic into separate files