fixed problems with mike's code -kl