What is the the origin of the phrase 'don't throw the baby out with the bathwater'?

Back in earlier times; before indoor plumbing; an entire family would use the same bath water and would bathe from the oldest to the youngest with the baby being the last to get a bath. The water would be so dirty at that point that you might lose the baby in the bath water and throw the baby out with the bath water.