fix logic compiler; refactor