Use proper array lenght

See PR #1233 and discussion therein.