fix the window resize function and some formatting