Made toEnum() dynamic