added distinctstores and fixed distinct types