update money algorithm