Remove unnecessary logical operations