bug fix for order3 function