separated resize function