Updated with smartpointers