added comments and tiedied up a bit