reversed some logic, removed negations