Fixing old bug setting the window focus in all the cases