bug fix: incorrect use of return value of splice