u/fjammes/dm-1338

Reviewing DM-1338
This function depends on global $DIR variable, globals are bad in general. Could you just pass it as an argument to a function?