10 digit extension number with 7 digit dialing

we want our switch to function just like a telco central office switch. extensions register with 10 digits, full npa-nxx-xxxx. the probelm is when local people in the same nxx only dial 7 digits we send the call out a trunk and then back in to reach another extension. if one dials all 10 then the call stays within the switch. we like freepbx and really don’t want to do a bunch of custom coding that will break next time we get an update. any body have a simple fixit for my problem?