Updated onload function