improve parsing to ensure directory is created