tidied up a little, added some comment.