Some refactor to avoid duplicated cod