some work on CPU implementation