refactoring smartpointer class