Redundant logic elimination in network functions