codes to build the ratio value asked by Sam