get_substone function and scan_dir modifications to handle substones