fixed a problem in reward function