rough demo implementation. have calculation error on CE