Bug fix with logical operators