modified waterbase.js