Aligned to master
Implemented O(n^2) method... need testing