bug fix saved current window instead of last