implement masterCode and exception