made the removal of the -999 pythonic, thanks to http://effbot.org/zone/python-list.htm
small typo fixed tmp -> x[0]