Functionalize water finding code