started major rewrite