incorporated changes from Percy.