length rewrite