start to refactor engine critical part