made binary search a template function