base engine refactory