dan rewrites the whole thing