Add proper structure and error handling