Moved resource loading into a method