Refactoring and output of the ratio to stdout