complete rewrite with ws