Fixed onload event handler bug