refactor out scope stuff for resize