Topic/refactor error handling