Restructured lazy loading code to not be inline with html