engine refactoring part 2