adding all of Dan's changes for reference