Improved design and optimization of subsurface flow constructed wetlands and sand filters