CLeaned up code a bit