touched up the code a bit