how is this for a start?

Ignoring the unidentified parts for now...

This line
if(results.value == -2094865891)

probably want to change this to >= or <=, be hard to hit that number right on the head.