Further refactor estimate_pi method