Improve slice function.