Refined code & added engine auto-switch