refactored Engine