reorganized and copied exact scripts from author