Use let instead of instance vars
Apply fix for active record double DISTINCT bug