Improved enum logic for performance and null safe