Cleaned up and commented the example code