fixed bug in value calc