Refactor error logs