improved initializeLoader method