logic initial refactor

logic initial refactor