#2 further work of rewriting PW engine