You above code has mistake. Even it is fixed, so many `&&`, `||` and `()` lead hard to understand. I think my suggestion is more easy to read.