Refactored inner width and height calculation