refactor(minErr): Remove duplicated code