improved natural_connect.m