Fix problem with window fucntion