helpers and DM code extracted into separate files