split function to sub function.