update

moved code around and updated comments