Added some untested potential error checking with max dimension