debugged problem with logical operators