fix invalid calculation