logic initial refactor