I assume that you place the |else| somewhere wrong.
It looks to me that this just decide if you are opening a running wrapper which url is the same as new |window.open| event.