this method is pretty complicated and is changing behavior on type. Possibly a spot we could do better.