Need to rewrite from scratch.