Refactor the divide String method