optimize rm commands for cleanup