fix logical and function