added functionality for calculation with negative numbers