Optimization of resizing controller code