complete rewrite of water flowing logic