Fixed window undefined issue