improved error handling for loader