PROTON-290: fix logic, needs a test