Applying best practices for Logging and error handling