fixing the excess directory creation problem