working version of split