fixed range error with label
fixed range error with label
added window event handler