Fixed an off by one error for handling bad windows