refactoring engine initialization