Reworked script to deal with associative array.