Handles errors and logging
Handles errors and logging