fixed boolean expression involving state changes in appDelegate