Added State Prediction Code
Tidy Up