engine class - refactoring in progress