use make_unique to simplify and make more resource safe