polished remove_entry code