refactoring remaining TODO in engine