added exception for when grid lengths are different