modified getReward.m