ex14 rewrite to use len