maybe it makes sense to allow undefined as type and only update the previous value if it is set
maybe it makes sense to allow undefined as type and only update the previous value if it is set