improve delete func