modified length/2 to work when the first argument is a variable - resolves #107