made resize function slightly smoother