Properly implemented tenary operation