Refactor relex2logic helper functions for better readablility
and for cpu savings