extract cfg dir code to re-use it