chagned rtype swtich from opcode to func