Fixed issue where local variable width and height were in global scope