Updated code for arc and weak references