fixed duplicate windows bug and added debug statements