refactor switch cases order