Fixing some minor bugs for delete func