Some refactor to avoid duplicated code