Rewrite

Complete rewrite