switch function order