adding conditional directory creation