Fixed bug with two windows of the same application, thanks @slaff66 for suggestion