revise stairing function and put unittest