rewrote script to use dictionary