added and tested checking for negative numbers