Valve logic