Added pi_bsearch()
Improved code readability