moved logic to engine