better code in trans switch function