bad boolean logic fixed