Improve the code for creating engine