bugfix: using scalar() instead of length() for array