Move 3rd rule to java code