Rewrote the rewarding method, fixing a few logic errors