Window resize bug fix