update to handle negative numbers