#27 added control if the directory doesn't exist