Refactor to use trait so data classes equality works correctly