Split the code into a library
Calculate the ratio from the plot we are interested in.
Added a simple binary search algorithm