working version of expand