add return state code for master and agent