Implemented smart pointer logic