added a Pin variable and lots of comments