added new sample for clustering + refactored some code in the original sample