Fixed typos, added array shape checking