refactor on undeclared variable getWidth