Replaced getAndDelete with inline code