complete rewrite (according to description)