Added isNaN detection for width