Replace == operator and conditions reorganized

* replaced == operator with equality operator;
* conditions reorganized in order to have more clear code.