CLeaned up some code