1. added code for detection window