fix stack usage in switch