Distinct function added

Basic Distinct function added, this is just a working prototype which should be fixed ASAP.