Optimze code by caching width and padding