Fixed bug dealing with negative numbers