moved handleWindowResize to be up among the primary functions