Completed O(n^6) and O(n^5) methods