Updated conditional function