Refactor handling of Result struct