Fix bug in split function