added two different implementations of split function