DRY-ed duplicate string functions

The `ratio` variable is constant. No need to split it three times