Add function to define smart-expand.