refactored structure of engine