updated to use own valueOf when available