Needham–Schroeder fix by adding opponent's identity to the first message Recap: Needham–Schroeder is as follows: 


$A \rightarrow B :   \{A, N_a\}_{pk_B}$
$B \rightarrow A :   \{N_a, N_b\}_{pk_A}$
$A \rightarrow B :   \{N_b\}_{pk_B}$


Then, there is a MITM attack by Lowe as follows:


$A \rightarrow C(A) :   \{A, N_a\}_{pk_C}$
$C(A)\rightarrow B     :   \{A, N_a\}_{pk_B}$
$B \rightarrow C(A) :   \{N_a,N_b\}_{pk_A}$
$C(A)\rightarrow  A       :   \{N_a,N_b\}_{pk_A}$
$A   \rightarrow  C(A)    :   \{N_b\}_{pk_C}$
$C(A)\rightarrow  B       :   \{N_b\}_{pk_B}$


Now $C(A)$ knows both $N_a$ and $N_b$, and he can compute the session key.
The solution that Lowe suggests is to put $B$'s identity to the second message:


$A \rightarrow B :   \{A, N_a\}_{pk_B}$
$B \rightarrow A :   \{N_a, N_b, B\}_{pk_A}$
$A \rightarrow B :   \{N_b\}_{pk_B}$


But what happens if we put B's identity into the first message?


$A \rightarrow B :   \{A, B, N_a\}_{pk_B}$
$B \rightarrow A :   \{N_a, N_b\}_{pk_A}$
$A \rightarrow B :   \{N_b\}_{pk_B}$


Is it still vulnerable to MITM attack or is it secure too?
It's easy to see that the man-in-the-middle attack you describe still applies to the modified protocol.


$A \rightarrow C(A) :   \{A, C, N_a\}_{pk_C}$
$C(A)\rightarrow B     :   \{A, B, N_a\}_{pk_B}$
$B \rightarrow C(A) :   \{N_a,N_b\}_{pk_A}$
$C(A)\rightarrow  A       :   \{N_a,N_b\}_{pk_A}$
$A   \rightarrow  C(A)    :   \{N_b\}_{pk_C}$
$C(A)\rightarrow  B       :   \{N_b\}_{pk_B}$


The idea why adding $B$'s identity to the second message might be helpful is that $B$ is telling the receiver who they are. So if $A$ sees that message they will realize that something is afoot, since they wanted to talk to $C$ but received a reply from $B$.¹

Whereas in your solution Alice tells the receiver who $A$ thinks they are. But since the man in the middle does not forward this message blindly, but in fact decrypts it and uses it to construct an entirely new message, this doesn't help in any way.



¹This only really helps if the public key encryption scheme used does not have malleable ciphertexts. Using encryption for authentication is just not a good idea and does not lead to robust solutions.