Replaced distinct by manual distinct