função de delete refatorada