fixing after_remove method for local storage and optimizing method