did 90% of the insertAndSplit functionality. Not sure if good implementation