Sleepy code for tommorrow

The code works last I checked. I am tired. Pull this please Ray.