Removing dangling reference