Crash occurs when deleting an object