use slice rather than splice.
minified version updated