fix calculation appWidth and newWidth