switched over to flags rather than sed and fixed type for mkdir