cleaned up and commented some