improvements to drain script