Added more robust splicing functionality