started complete rewrite