Fix logic mess, split conditions to AND / OR ones

Change-Id: If06a353f169e5ac02322794f5b74a59081e9a1c2
Merge "Fix logic mess, split conditions to AND / OR ones"