Moved class instantiation outside render loop