A new algorithm is introduced for analyzing possible nestings in mobile ambient calculus. It improves both time and space complexities of the technique proposed by Nielson and Seidl. The improvements are achieved by enhancing the data structure representations, and by reducing the computation to the control ow analysis constraints that are e ectively necessary to get to the least solution. These theoretical results are also supported by experimental tests run on a Java-based tool that implements a suite of algorithms for nesting analysis of mobile ambients. c 2004 Elsevier Ltd. All rights reserved.