Refactored water checking code