completed script
fixed final bugs