Implementing split function