To make this just that much better, still accomplishing the same task, but in certain circumstances creating much less lag. Use this command instead:

/entitydata @e[tag=!handled] {NoAI:1,Tags:["handled"]}

This will make the command not even attempt to alter an entity that it has already altered. In a world with several other mechanisms it is crucial to be as accurate as you can. Minimizing any and all possible unnecessary iterations. Sure in this case it seems unreasonable, but when you start doing things that require over 100 command blocks, it is necessary to already have this habit of writing, otherwise you will have unavoidable amounts of lag making it impossible to continue without learning this the hard way and starting all over.

It actually has one very important difference, the "b". It sets the variable type to byte, while leaving it off is an int. Since NoAI is a byte we must feed it a byte or it will throw the data out entirely.