Performance optimization suggested by MorrisR2 (issue #63)