rewrite list-length function