fixed bugs when width and height are NaN