added distinct functionality