Fix last child when there's a limit and simplify code