Fixed correspondence function to use correct window