add flag to control exclude recursively or not