tidy up

removed unnecessary code and improved negative number recognition.