use path.dirname instead of self substring