fix crash with negative values