Implemented rectangle dimensions check to avoid OutofMemoryException