Fix leftx and rightx, add width variable