have an onload function, is not 100% smooth yet