Better onload function code