GetCode function