add checked cast and UniquePtr