both scripts work, need some cleanup and more testing