added back in some parts that were accidentally deleted in previous edit.