Added binary search and permutation functions