added a boat load of comments for clarity