changed check of dimension to check of length