modified to adjust size automatically