Added width and height max checking