Cant remember where I read this, but I realized a while back the folly of "rewriting your code". Your code looks messy because it works. Its the result of weeks of testing and bug fixes. It can handle special cases and is robust.
Many a times, to start of, a clever 5 or 10 lines would suffice. But the moment you start testing it for production, it'd require more and more logic to handle _all_ the cases.