refactoring of "resize" functons