In this paper we present an automatic optimal baseform determination algorithm. Given a set of subword Hidden Markov Models and acoustic tokens of a specific word, we apply the tree-trellis N-best search algorithm to find the optimal baseforms (transcriptions) in the maximum likelihood sense. The proposed algorithm is used in an iterative manner, creating a series of lexica trained from the given acoustic tokens. The DARPA Resource Management (RM) database was used for evaluating the new baseform optimisation algorithm. When compared to the initial lexicon derived from the DARPA RM-distribution, improvements of recognition rates have been obtained for all lexica trained with the baseform optimisation algorithm. An analysis of the relative performances of the lexica is given.